﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YY.Admin.Core.Option;
using YY.Admin.Core.SqlSugar;

namespace YY.Admin.Setup
{
    public static class ProjectOptions
    {
        /// <summary>
        /// 注册项目配置选项到Prism容器
        /// </summary>
        public static IContainerRegistry AddProjectOptions(
            this IContainerRegistry containerRegistry,
            IConfiguration configuration)
        {
            // 绑定数据库连接配置到对象
            var dbOptions = configuration.GetSection("DbConnection").Get<DbConnectionOptions>();

            // 注册配置实例
            containerRegistry.RegisterInstance(dbOptions);

            return containerRegistry;
        }
    }
}
